/*
 * Project Name: jmax
 * File Name: PlayCenterController.java
 * Copyright: Copyright(C) 1985-2016 ZKTeco Inc. All rights reserved.
 */
package com.xdtech.play.controller;

import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.xdtech.common.utils.DateUtil;
import com.xdtech.common.utils.DateUtil.DateStyle;
import com.xdtech.play.service.PlayMemberService;
import com.xdtech.play.service.PlayStartService;
import com.xdtech.play.vo.PlayMemberItem;
import com.xdtech.play.vo.PlayStartItem;
import com.xdtech.sys.aspect.SystemControllerLog;
import com.xdtech.web.model.ResultMessage;

/**
 * 
 * @version TODO 添加版本
 * @see 相关类或方法，不需要请删除此行
 * @since 2016-5-9 下午9:01:00
 */
@Controller
@Scope("prototype")
public class PlayCenterController
{
	private Log log = LogFactory.getLog(PlayCenterController.class);
	@Autowired
	private PlayMemberService playMemberService;
	@Autowired
	private PlayStartService playStartService;
	@RequestMapping(value="/playCenter.do",params = "playCenter")
	public ModelAndView skipPlayCenter() {
		return new ModelAndView("play/playCenter/playCenter_ftl");
	}
	
	@RequestMapping(value="/playCenter.do",params = "skip")
	public ModelAndView skip(HttpServletRequest request,String page,Long memberId) {
		if (memberId!=null) {
			request.setAttribute("operationDate", DateUtil.getDate(new Date(), DateStyle.YYYY_MM_DD_HH_MM_SS));
			request.setAttribute("playMemberItem", playMemberService.loadPlayMemberItem(memberId));
		}
		return new ModelAndView("play/playCenter/"+page+"_ftl");
	}
	
	@RequestMapping(value="/playCenter.do",params = "saveStartInfo")
	@ResponseBody
	@SystemControllerLog(description = "开庄")
	public ResultMessage saveStartInfo(PlayStartItem item) {
		ResultMessage r = playStartService.saveStartInfo(item);
		return r;
	}
	
}
